<?php include("../../includes/includes.php"); ?>
<?
connect($config);
$loggedInTeam = getLoggedInTeam();

if ($loggedInTeam == null) {
	header( 'Location: ../notAuthenticated.php' );
	die();
}
$leagueId = $_SESSION['leagueId'];
$isYourPick = false;
if ($loggedInTeam != null) {
   $isYourPick = isYourPick($leagueId, $loggedInTeam->coachName);
   $userSettings = getUserSettings($loggedInTeam->coachName, $leagueId);
}
$currentPick = getCurrentPick($leagueId);
$availPlayers = getAPL($leagueId);
$settings = getSystemSettings($leagueId);
$ltiList = getLtisForCoach($loggedInTeam->id);

$currentRound = getCurrentRound();
$round = $currentRound;
if (isset($_GET['round'])) {
	$round = $_GET['round'];
}

$myTradesPage = 1;
if (isset($_POST['myTradesPage'])) {
	$myTradesPage = $_POST['myTradesPage'];
}
$allTradesPage = 1;
if (isset($_POST['allTradesPage'])) {
	$allTradesPage = $_POST['allTradesPage'];
}
$reviewPage = 1;
if (isset($_POST['reviewPage'])) {
	$reviewPage = $_POST['reviewPage'];
}
$maxPerPage = -1;
if ($loggedInTeam != null) {
	$maxPerPage = $userSettings->getSettingValue(SettingType::TradesPerPage);
}

?>
<!DOCTYPE html>
<html>

	<body onKeyPress="return disableEnterKey(event)">
<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title>MasoCoach Program</title>
        <style type="text/css">
				/* Reset Browser CSS */
				html, body, div, span, applet, object, iframe,
				h1, h2, h3, h4, h5, h6, p, blockquote, pre,
				a, abbr, acronym, address, big, cite, code,
				del, dfn, em, img, ins, kbd, q, s, samp,
				small, strike, strong, sub, sup, tt, var,
				b, u, i, center,
				dl, dt, dd, ol, ul, li,
				fieldset, form, label, legend,
				caption, tbody, tfoot, thead, tr, th, 
				article, aside, canvas, details, embed,
				figure, figcaption, footer, header, hgroup,
				menu, nav, output, ruby, section, summary,
				time, mark, audio, video {
					margin: 0;
					padding: 0;
					border: 0;
					xfont: inherit;
				}
				/* HTML5 display-role reset for older browsers */
				article, aside, details, figcaption, figure,
				footer, header, hgroup, menu, nav, section {
					display: block;
				}
				body {
					line-height: 1;
				}
				ol, ul {
					list-style: none;
				}
				blockquote, q {
					quotes: none;
				}
				blockquote:before, blockquote:after,
				q:before, q:after {
					content: '';
					content: none;
				}
				.buttonStyle {width: 100px; height: 30px};
		</style>
		<link type="text/css" href="../../../css/redmond/jquery-ui-1.8.14.custom.css" rel="stylesheet" />
		<link type="text/css" href="../../../css/domTT.css" rel="stylesheet" />
		<link type="text/css" href="../../../css/simpleToolTip.css" rel="stylesheet" />
		<script type="text/javascript" src="../../../js/jquery-1.5.1.min.js"></script>
		<script type="text/javascript" src="../../../js/jquery-ui-1.8.14.custom.min.js"></script>
		<script type="text/javascript" src="../../../js/player.js"></script>

		<script type="text/javascript" src="../../../js/domTT/alphaAPI.js"></script>
		<script type="text/javascript" src="../../../js/domTT/domLib.js"></script>
		<script type="text/javascript" src="../../../js/domTT/domTT.js"></script>
		<script type="text/javascript" src="../../../js/domTT/domTT_drag.js"></script>
		<script type="text/javascript" src="../../../js/domTT/fadomatic.js"></script>
		<script type="text/javascript">
			$(function(){
				$('#tabs').tabs();
			});
		</script>
		<style>
			/*demo page css*/
			body{ font: 80% "Trebuchet MS", sans-serif; margin: 5px; margin-top: 20px;}
			.demoHeaders { margin-top: 2em; }
			#dialog_link {padding: .4em 1em .4em 20px;text-decoration: none;position: relative;}
			#dialog_link span.ui-icon {margin: 0 5px 0 0;position: absolute;left: .2em;top: 50%;margin-top: -8px;}
			ul#icons {margin: 0; padding: 0;}
			ul#icons li {margin: 2px; position: relative; padding: 4px 0; cursor: pointer; float: left;  list-style: none;}
			ul#icons span.ui-icon {float: left; margin: 0 4px;}
		</style>
	</head>
	<script>
		var players = new Array();
		<?
		//usort($availPlayers, "compareAvailPlayers");
		$count = count($availPlayers);
		for ($i = 0; $i < $count; $i++) {?>
		players[<?echo $i?>] = new Player(<?echo $availPlayers[$i]->id?>, "<?echo $availPlayers[$i]->getDescription()?>");
		<?}?>
		
		function addNewPlayer(frm) {
			var player = document.getElementById("availPlayers").options[document.getElementById("availPlayers").selectedIndex];
			document.getElementById('newPlayerDiv').innerHTML += player.text;
			frm.newPlayer.value = player.value;
			frm.availPlayers.options[frm.availPlayers.selectedIndex] = null
		}

		function submitPageNumberFormFromTrades() {
			document.forms['pageNumberForm'].action += "#tabs-Trades"; 
			document.forms['pageNumberForm'].submit();
		}
		function submitPageNumberFormFromHome() {
			document.forms['pageNumberForm'].action += ""; 
			document.forms['pageNumberForm'].submit();
		}		
		function submitPageNumberForm(bookMark) {
			document.forms['pageNumberForm'].action += bookMark; 
			document.forms['pageNumberForm'].submit();
		}
function disableEnterKey(e)
{
     var key;
     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox
     if(key == 13)
          return false;
     else
          return true;
}
	</script>

		<div id="tabs">
			<ul>
                <?if ($loggedInTeam != null) {?>
				<li><a href="#tabs-Home">Home</a></li>
                                <?}?>
				<?if ($loggedInTeam == null || $userSettings->getSettingValue(SettingType::ShowDraftTab) == "YES") {?>
				<li><a href="#tabs-Draft">Draft</a></li>
				<?}?>
				<?if ($settings->seasonInProgress == "YES") {?>
		        <li><a href="#tabs-DisplayRound">Results</a></li>
				<li><a href="#tabs-SelectedTeam">Pick Team</a></li>
				<li><a href="#tabs-SelectedTeamsForWeek">Teams for Round</a></li>
				<li><a href="#tabs-LTISpud">LTI/Spud</a></li>
		        <?}?>
				<li><a href="#tabs-APL">APL</a></li>		        
				<?if ($loggedInTeam == null || $settings->trades == "ON") {?>
				<li><a href="#tabs-Trades">Trades</a></li>
				<?}?>
                <?if ($loggedInTeam != null) {?>
				<li><a href="#tabs-YourTeam">Your Team</a></li>
                <?}?>
				<li><a href="#tabs-SelectedTeams">Selected Teams</a></li>
				<?if ($isYourPick) {?>
					<!--li><a href="#tabs-MMP">Make my Pick</a></li-->
				<?}?>
				<?if ($loggedInTeam != null && $userSettings->getSettingValue(SettingType::ShowPrefTab) == "YES") {?>
				<li><a href="#tabs-PREF">Preferences</a></li>
				<?}?>
				<?if ($loggedInTeam != null && KPPStatusBoard::isAuthentic($loggedInTeam->coachName) && $userSettings->getSettingValue(SettingType::ShowReviewTab) == "YES") {?>
				<li><a href="#tabs-KPPStatusReview">KPP Status Review</a></li>
				<?}?>
				<!--li><a href="#tabs-PreSeason">Pre Season Cup</a></li -->
				<li><a href="#tabs-Fixture">Fixture</a></li>
                <?if ($loggedInTeam != null) {?>
				<li><a href="#tabs-Settings">Settings</a></li>
                <?}?>
				<?if ($loggedInTeam == null || $userSettings->getSettingValue(SettingType::ShowArchiveTab) == "YES") {?>
				<li><a href="#tabs-Archive">Archive</a></li>
				<?}?>				
			</ul>
            <?if ($loggedInTeam != null) {?>
			<div id="tabs-Home">
				<?
				$forAdmin = false;
				$currentTeam = $loggedInTeam;
				?>
				<?php include("yourHome.php"); ?>
			</div>
            <?}?>
			<?if ($loggedInTeam == null || $userSettings->getSettingValue(SettingType::ShowDraftTab) == "YES") {?>
			<div id="tabs-Draft">
				<?php include("draftHome.php"); ?>
			</div>
			<?}?>
			<?if ($settings->seasonInProgress == "YES") {?>

			<div id="tabs-DisplayRound">
				<?if ($round < $currentRound || $round == 51 || $round == 53 || $round == 54) {?>
				<?php include("../round/displayRoundAsHTML.php"); ?>
				<?} else if ($round == $currentRound && getCurrentRoundStatus() == RoundStatusType::Open) {
					$round--;
				?>
				<?php include("../round/displayRoundAsHTML.php"); ?>				
				<?} else if ($round == $currentRound) {
				?>
				<?php include("../round/displayRoundAsHTML.php"); ?>
				<?} else {?>
					<?php include("../round/displayRound.php"); ?>
				<?}?>
			</div>
			<div id="tabs-SelectedTeam">
				<?php include("../round/selectedTeam.php"); ?>
			</div>
			<div id="tabs-SelectedTeamsForWeek">
				<?php include("../round/selectedTeamsForWeek.php"); ?>
			</div>
			<div id="tabs-LTISpud"><?php include("ltiSpud.php"); ?></div>
			<?}?>
			<div id="tabs-APL">
				<?php include("displayAPL.php"); ?>
			</div>
			<?if ($loggedInTeam == null || $settings->trades == "ON") {?>
			<div id="tabs-Trades">
				<?php include("../trades/trades.php"); ?>
			</div>
			<?}?>
            <?if ($loggedInTeam != null) {?>
			<div id="tabs-YourTeam">
				<?php include("yourTeam.php"); ?>
			</div>
            <?}?>
			<div id="tabs-SelectedTeams">
				<?php include("selectedTeams.php"); ?>
			</div>
			<?if ($isYourPick) {?>
			<!--div id="tabs-MMP">
				<?php include("../makePickAndPref/makeMyPick.php"); ?>
			</div-->
			<?}?>
			<?if ($loggedInTeam != null && $userSettings->getSettingValue(SettingType::ShowPrefTab) == "YES") {?>
			<div id="tabs-PREF">
				<?php include("../makePickAndPref/makePreference.php"); ?>
			</div>
			<?}?>
			<?if ($loggedInTeam != null && KPPStatusBoard::isAuthentic($loggedInTeam->coachName) && $userSettings->getSettingValue(SettingType::ShowReviewTab) == "YES") {?>
			<div id="tabs-KPPStatusReview">
				<?php include("../kppStatusReview/kppStatusReview.php"); ?>
			</div>
			<?}?>
			<!--div id="tabs-PreSeason">
				<?php include("../round/preSeasonScoresWeek3.php"); ?>
			</div-->
			<div id="tabs-Fixture">
				<?php include("../html/fixture-" . $leagueId . ".htm"); ?>
			</div>			
			<?if ($loggedInTeam != null) {?>
			<div id="tabs-Settings">
				<?php include("../admin/settings.php"); ?>
			</div>
            <?}?>
			<?if ($loggedInTeam == null || $userSettings->getSettingValue(SettingType::ShowArchiveTab) == "YES") {?>
			<div id="tabs-Archive">
				<iframe width="950" height="800" src="../../../archive/archiveIndex.htm"></iframe>
			</div>
			<?}?>
		</div>
		<form id="pageNumberForm" name="pageNumberForm" action="homePage.php" method="post">
			<input type="hidden" name="myTradesPage" value="<?echo $myTradesPage?>">
			<input type="hidden" name="allTradesPage" value="<?echo $allTradesPage?>">
			<input type="hidden" name="reviewPage" value="<?echo $reviewPage?>">
		</form>
		
		<iframe src="#" width="0" height="0" id="hiddenFrame" name="hiddenFrame" border="0" />
	</body>
</html>
<?mysql_close();?>